package service.impl;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import model.User;
import service.UserService;

import java.util.List;
import java.util.Map;

public class UserServiceImpl implements UserService {
    //private UserDao userDao = new UserDaoImpl();
    //new UserDaoImpl();不让自己创建


    private UserDao userDao;
    private int num;
    private String name;
    private List<String> list;
    private Map<String,String> map;

    public UserServiceImpl(UserDao userDao, int num, String name, List<String> list, Map<String, String> map) {
        this.userDao = userDao;
        this.num = num;
        this.name = name;
        this.list = list;
        this.map = map;
    }

    public void setMap(Map<String, String> map) {
        this.map = map;
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public List<User> queryUsers() {
        System.out.println("查询");
        return userDao.queryUsers();
    }

    @Override
    public User queryUserById(int user_id) {
        return userDao.queryUserById(user_id);
    }

    @Override
    public void addUser(User user) {
        userDao.addUser(user);
        System.out.println("UsrService被执行！");
        System.out.println(num);
        System.out.println(name);
        System.out.println("遍历list集合");
        for (String s : list) {
            System.out.println(s);
        }

        System.out.println("遍历Map集合");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry);
        }
    }

    @Override
    public void delUserById(int user_id) {
        userDao.delUserById(1);
    }
}
